from flask_admin.form import FileUploadField
from wtforms import validators

from ..constants import tasks_media_folder
from .base import MyBaseModelView


class CalendarTaskModelView(MyBaseModelView):
    column_list = ("day", "calendar", "task_text_ru")

    form_excluded_columns = ("created_at", "updated_at")

    column_labels = {
        "day": "День задачи",
        "task_text_ru": "Текст задачи (ru)",
        "task_text_en": "Текст задачи (en)",
        "task_text_uk": "Текст задачи (ua)",
        "calendar": "Календарь",
        "media_filename": "Фото / видео",
    }

    form_extra_fields = {
        "media_filename": FileUploadField(
            label="Фото / видео (максимум 10 мб)",
            validators=[validators.DataRequired()],
            base_path=tasks_media_folder,
            allow_overwrite=True,
            allowed_extensions=["png", "jpg", "jpeg", "mp4"],
        )
    }
